//
//  SCNInvestDetailViewModel.swift
//  ShoucainuSwift
//
//  Created by 王家旭 on 2017/11/22.
//  Copyright © 2017年 Riluee. All rights reserved.
//

import UIKit
import ObjectMapper

class SCNInvestDetailViewModel: NSObject {

    func requestInvestDetailInvestDetailNew(_ param: [String : String], successBlock:@escaping ((_ dataresult: SCNInvestDetailDataresultModel) -> Void)) -> Void {
        
        SCNRequestManager.postRequest(param, URL: SCNRequestAPI.invest().investDetailNew) { (response) in
            
            let investDetailModels = Mapper<SCNInvestDetailModel>().map(JSONObject: response.result.value)
            
            if let tmp = investDetailModels?.dataresult {
                successBlock(tmp)
            }
        }
        
    }
}

class SCNInvestDetailModel: Mappable {
    
    var dataresult: SCNInvestDetailDataresultModel?
    var errmsg: String?
    var status: Int?
    var servertime: Int?
    
    required init?(map: Map) {
        mapping(map: map)
    }
    
    func mapping(map: Map) {
        dataresult <- map["dataresult"]
        errmsg <- map["errmsg"]
        status <- map["status"]
        servertime <- map["servertime"]
    }
    
    
    
}

class SCNInvestDetailDataresultModel: Mappable {
   
    ///详情
    var content: String?
    ///进度
    var progress: Float?
    ///担保公司
    var assure: String?
    ///标的图标
    var icon: String?
    ///是否新手
    var isfirsttender: Bool?
    ///是否抢标
    var istime: Bool?
    ///标的时间
    var loandue: String?
    ///标的总金额
    var loanmoney: String?
    ///标的总金额（单位）
    var loanmoneyFormat:String?
    ///标的利率
    var rate: String?
    ///标的SN编码
    var loansn: String?
    ///标的状态
    var loanstatus: Float?
    ///最低投标额度
    var mintendermoney: String?
    ///可投标的额度
    var maxtendermoney: String?
    ///返息方式
    var repay: String?
    ///招标时间
    var starttime: String?
    ///标的标题
    var title: String?
    ///<内容。状态。URL>
    var activity: Dictionary<String, Any>?
    ///是否秒杀
    var is_activity: Bool?
    ///开始时间
    var start_time: String?
    ///当前请求时间
    var now_time: String?
    ///加息
    var extrarate: String?
    ///加息钱的收益率
    var originrate: String?
    ///标的类型
    var typeid: Int?
    ///特约标，角标状态
    var show_rmb: Int?
    
    
    required init?(map: Map) {
        mapping(map: map)
    }
    
    func mapping(map: Map) {
        content <- map["content"]
        progress <- map["progress"]
        assure <- map["assure"]
        icon <- map["icon"]
        isfirsttender <- map["isfirsttender"]
        istime <- map["istime"]
        loandue <- map["loandue"]
        loanmoney <- map["loanmoney"]
        loanmoneyFormat <- map["loanmoneyFormat"]
        rate <- map["rate"]
        loansn <- map["loansn"]
        loanstatus <- map["loanstatus"]
        mintendermoney <- map["mintendermoney"]
        maxtendermoney <- map["maxtendermoney"]
        repay <- map["repay"]
        starttime <- map["starttime"]
        title <- map["title"]
        activity <- map["activity"]
        is_activity <- map["is_activity"]
        start_time <- map["start_time"]
        now_time <- map["now_time"]
        extrarate <- map["extrarate"]
        originrate <- map["originrate"]
        typeid <- map["typeid"]
        show_rmb <- map["show_rmb"]
    }
    
    
}
